package cn.yx.framework.configuration;


import cn.com.yx.ms.service.IMqService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

import javax.annotation.Resource;

/**
 * 添加WebSocket配置 on 2017/3/15.
 */
//@ConditionalOnWebApplication
//@EnableWebSocketMessageBroker
@Configuration
public class WebSocketConfig {//extends AbstractWebSocketMessageBrokerConfigurer {

    @Resource
    private IMqService iMqService;

    @Bean
    public MyWebSocket myWebSocket() {
        return new MyWebSocket(iMqService);
    }

//    @Bean
//    public ServerEndpointExporter serverEndpointExporter() {
//        return new ServerEndpointExporter();
//    }
//@Override
//public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
//    registry.addHandler(myHandler(), "/").setAllowedOrigins("*");
//}
//
//    @Bean
//    public SpringWebSocketHandler myHandler() {
//        return new SpringWebSocketHandler();
//    }
}
